/* energyMib.c - IDB+ Module source for energyMib.mi2. */

/* Copyright 2013 Wind River, Inc. */
// #include "copyright_wrs.h"
/*
modification history
--------------------
xxx,22Mar13,idb Created by IDBGEN. Ver 2.28
%%BeginUserCode energyMib_Modifications
%%EndUserCode   energyMib_Modifications
*/

/*
DESCRIPTION
This module defines the IDB+ structures and IDB+ Object handler routines to
access the IDB+ objects defined in energyMib.mi2.

INCLUDE FILES: energyMib.h
*/

/* Includes */
#include "neos_vx_win.h"
#include "jialianMib_function.h"
#include "idbLib.h"
#include "energyMib.h"

/* %%BeginUserCode energyMib_IncludeFiles */
/* %%EndUserCode   energyMib_IncludeFiles */

/* Defines */
/* %%BeginUserCode energyMib_Defines */
/* %%EndUserCode   energyMib_Defines */

/* Globals */
/* %%BeginUserCode energyMib_Globals */
/* %%EndUserCode   energyMib_Globals */

/* Locals */
LOCAL char * moduleName = "energyMib";
/* %%BeginUserCode energyMib_Locals */
/* %%EndUserCode   energyMib_Locals */

/* Prototypes */
LOCAL STATUS energyMibScalarHandler ( idbRequest_t request, idb_t * idb );

/* %%BeginUserCode energyMib_Prototypes */
/* %%EndUserCode   energyMib_Prototypes */


/****************************************************************************
* IDB+ Module Object Descriptors
*/

LOCAL idbObjDesc_t qoeHour_objDesc[] = {
  { qoeHour, 1, 4, /* localId=0  1.3.6.1.4.1.123456.1.3.1 */
    { 0, 0 }, IDB_Unsigned32, IDB_READ,
    (IDB_VALID), energyMibScalarHandler,
    (char *)0, "energyMib:qoeHour" },
  { 0 }
};

LOCAL idbObjDesc_t qoeDay_objDesc[] = {
  { qoeDay, 2, 4, /* localId=1  1.3.6.1.4.1.123456.1.3.2 */
    { 0, 0 }, IDB_Unsigned32, IDB_READ,
    (IDB_VALID), energyMibScalarHandler,
    (char *)0, "energyMib:qoeDay" },
  { 0 }
};

LOCAL idbObjDesc_t qoeWeek_objDesc[] = {
  { qoeWeek, 3, 4, /* localId=2  1.3.6.1.4.1.123456.1.3.3 */
    { 0, 0 }, IDB_Unsigned32, IDB_READ,
    (IDB_VALID), energyMibScalarHandler,
    (char *)0, "energyMib:qoeWeek" },
  { 0 }
};

LOCAL idbObjDesc_t qoeMonth_objDesc[] = {
  { qoeMonth, 4, 4, /* localId=3  1.3.6.1.4.1.123456.1.3.4 */
    { 0, 0 }, IDB_Unsigned32, IDB_READ,
    (IDB_VALID), energyMibScalarHandler,
    (char *)0, "energyMib:qoeMonth" },
  { 0 }
};

LOCAL idbObjDesc_t water_objDesc[] = {
  { water, 5, 4, /* localId=4  1.3.6.1.4.1.123456.1.3.5 */
    { 0, 0 }, IDB_Unsigned32, IDB_READ,
    (IDB_VALID), energyMibScalarHandler,
    (char *)0, "energyMib:water" },
  { 0 }
};

LOCAL idbObjDesc_t gas_objDesc[] = {
  { gas, 6, 4, /* localId=5  1.3.6.1.4.1.123456.1.3.6 */
    { 0, 0 }, IDB_Unsigned32, IDB_READ,
    (IDB_VALID), energyMibScalarHandler,
    (char *)0, "energyMib:gas" },
  { 0 }
};

/*****************************************************************************
* IDB+ Module OID Table
*
* The OID list below (e.g.,{1,3,6,1, ...}) is the OID prefix minus the
* last sub-identifier.  The last sub-identifier is found in the
* object descriptor idbObjDesc_t structure.
*/

LOCAL idbOidTable_t oidTable[] = {
  /*   0: Scalar Object -- qoeHour */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,3}, 10,   /*lint !e785 */
    0, 1, { 0 },
    qoeHour_objDesc },

  /*   1: Scalar Object -- qoeDay */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,3}, 10,   /*lint !e785 */
    0, 1, { 0 },
    qoeDay_objDesc },

  /*   2: Scalar Object -- qoeWeek */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,3}, 10,   /*lint !e785 */
    0, 1, { 0 },
    qoeWeek_objDesc },

  /*   3: Scalar Object -- qoeMonth */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,3}, 10,   /*lint !e785 */
    0, 1, { 0 },
    qoeMonth_objDesc },

  /*   4: Scalar Object -- water */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,3}, 10,   /*lint !e785 */
    0, 1, { 0 },
    water_objDesc },

  /*   5: Scalar Object -- gas */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,3}, 10,   /*lint !e785 */
    0, 1, { 0 },
    gas_objDesc },

  { IDB_TERMINATOR }
};

/*****************************************************************************
* IDB+ Module Translate Table
*/

LOCAL idbXlateTable_t xlateTable[] = {
    { &oidTable[  0], &qoeHour_objDesc[0] },
    { &oidTable[  1], &qoeDay_objDesc[0] },
    { &oidTable[  2], &qoeWeek_objDesc[0] },
    { &oidTable[  3], &qoeMonth_objDesc[0] },
    { &oidTable[  4], &water_objDesc[0] },
    { &oidTable[  5], &gas_objDesc[0] },

    { 0 }
};

/******************************************************************************
* User Local Functions.
*/

/* %%BeginUserCode energyMib_UserFunctions */
/* %%EndUserCode   energyMib_UserFunctions */


/****************************************************************************
*
* energyMibInit - initialize/register energyMib and objects.
*
* This routine initializes the modules IDB routines.
*
* RETURNS: SNMP_OK or SNMP_ERROR
*
* ERRNO: N/A
*/

STATUS energyMibInit
    (
    void * parm1,
    void * parm2
    )
    {
    STATUS    rc;

    /* %%BeginUserCode energyMibInit_Prolog */
    /* %%EndUserCode   energyMibInit_Prolog */

    rc = SNMP_OK;

    /* %%BeginUserCode energyMibInit_Body */
    /* %%EndUserCode energyMibInit_Body */

    /* Register the module's information with IDB+ engine */
    rc = idbModuleRegister( moduleName, &xlateTable[0] );

    /* %%BeginUserCode energyMibInit_Epilog */
    /* %%EndUserCode   energyMibInit_Epilog */

    return( rc );
    }

/******************************************************************************
*
* energyMibTerminate - Terminate energyMib and objects.
*
* This routine de-initializes the IDB module functions.
*
* RETURNS: SNMP_OK or SNMP_ERROR
*
* ERRNO: N/A
*/

STATUS energyMibTerminate
    (
    void * parm
    )
    {
    STATUS    rc;

    /* %%BeginUserCode energyMibTerminate_Prolog */
    /* %%EndUserCode   energyMibTerminate_Prolog */

    rc = SNMP_OK;

    /* De-register the module's information with IDB+ engine */
    idbModuleDeRegister( moduleName );

    /* %%BeginUserCode energyMibTerminate_Epilog */
    /* %%EndUserCode   energyMibTerminate_Epilog */

    return( rc );
    }

/******************************************************************************
*
* energyMibScalarHandler - handles all scalar objects.
*
* This routine handles all scalar objects for this IDB+ Module.
*
* RETURNS: SNMP_OK or SNMP_ERROR
*
* ERRNO: N/A
*/

LOCAL STATUS energyMibScalarHandler
    (
    idbRequest_t request,
    idb_t * idb
    )
    {
    STATUS    rc;

    /* %%BeginUserCode energyMibScalarHandler_Prolog */
    /* %%EndUserCode   energyMibScalarhandler_Prolog */

    rc = SNMP_OK;

    /* Validate the Scalar indexSubIdCount and instance value */
    if ( idbScalarValidate( request, idb ) == SNMP_ERROR )
        return idbErrorRequestMap( request );

    switch( idb->localId )
    {
    default:
        rc = idbErrorNoSuchInstance();
        break;

    /* ================================================================= */
    case qoeHour:    /* Unsigned32, read-only */
        {
        /* %%BeginUserCode qoeHour_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:
            break;
        }

        /* %%EndUserCode   qoeHour_Body */
        }
        break;

    /* ================================================================= */
    case qoeDay:    /* Unsigned32, read-only */
        {
        /* %%BeginUserCode qoeDay_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:
            break;
        }

        /* %%EndUserCode   qoeDay_Body */
        }
        break;

    /* ================================================================= */
    case qoeWeek:    /* Unsigned32, read-only */
        {
        /* %%BeginUserCode qoeWeek_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:
            break;
        }

        /* %%EndUserCode   qoeWeek_Body */
        }
        break;

    /* ================================================================= */
    case qoeMonth:    /* Unsigned32, read-only */
        {
        /* %%BeginUserCode qoeMonth_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:
            break;
        }

        /* %%EndUserCode   qoeMonth_Body */
        }
        break;

    /* ================================================================= */
    case water:    /* Unsigned32, read-only */
        {
        /* %%BeginUserCode water_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:
            break;
        }

        /* %%EndUserCode   water_Body */
        }
        break;

    /* ================================================================= */
    case gas:    /* Unsigned32, read-only */
        {
        /* %%BeginUserCode gas_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:
            break;
        }

        /* %%EndUserCode   gas_Body */
        }
        break;

    }

    /* %%BeginUserCode energyMibScalar_Epilog */
    /* %%EndUserCode   energyMibScalar_Epilog */

    return( rc );
    }

